package com.lfsenior;

import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.ext.ExceptionMapper;
import javax.ws.rs.ext.Provider;
import java.util.HashMap;
import java.util.Map;

/**
 * Created by dlupan on 2018/9/17
 */
@Provider
public class ServerErrorHandler  implements ExceptionMapper<Throwable> {
    @Override
    public Response toResponse(Throwable exception) {
        Map<String,Object> result=new HashMap<>();
        result.put("result",false);
        result.put("msg",exception.getMessage());
        return Response.ok(result, MediaType.APPLICATION_JSON).build();
    }
}
